package com.es.disped.web.controller.oj.sourcecodeuser;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.es.disped.api.oj.sourcecodeuser.HustSourceCodeUserService;
import com.es.disped.common.annotation.DynamicDataSource;
import com.es.disped.common.model.MsgModel;
import com.es.disped.core.controller.BaseController;
import com.es.disped.dao.oj.model.SourceCodeUser;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;

/**
 * @author Anson<br>
 *	Copyright by EasyShare 2019<br>
 *  
 *  All right reserved<br>
 *
 *  Created on 2019年7月21日 下午10:38:58<br>
 *  名称：SourceCodeUserController.java<br>
 *  描述：用户源码管理<br>
 */
@Api("用户源码管理")
@Controller
@RequestMapping("/oj/source/user")
public class SourceCodeUserController extends BaseController{
	
	@Autowired
	HustSourceCodeUserService hustSourceCodeUserService;

	@ApiOperation(value="获取判题源码",response=MsgModel.class,httpMethod="POST",notes="获取提交的源码")
	@RequestMapping(value="/code",method=RequestMethod.POST)
	@DynamicDataSource
	public @ResponseBody MsgModel getSource(@RequestBody @ApiParam(name="sourceCodeUser",value="用户源码对象",required=true) SourceCodeUser sourceCodeUser)
	{
		SourceCodeUser res=hustSourceCodeUserService.selectByPrimaryKey(sourceCodeUser.getSolutionId());
		return this.resultMsg(!this.isNull(res)?HttpStatus.OK.value():HttpStatus.EXPECTATION_FAILED.value(),
				!this.isNull(res)?"加载成功":"获取失败",!this.isNull(res)?res:"");
	}
	
}
